<!doctype html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0" />
    <title>优家舒适圈</title>
    <link rel="stylesheet" type="text/css" href="__STATIC__/index/css/mg.css">
    <script src="__STATIC__/index/js/jquery.min.js"></script>
    <script src="__STATIC__/index/js/mg.js"></script>
    <style>
        .input,#company{
            margin-left: 0px;
        }
     .item-title{
        display: inline-block;
        width: 16%;
        text-align: right;
        margin-right: 5%;
     }   
     .item-content{
        display: inline-block;
        width: 75%;
        text-align: left;
     }  
     .item-content input::-webkit-input-placeholder,.item-content select{
         font-size: 14px;
     }
     #tel{
        width: 50%;
     } 
    </style>
</head>
<body>
<div class="register_head">
    <img id="back" src="__STATIC__/index/img/return.png">
    <p>新用户注册</p>
</div>
<form id="form" method="post" action="{:Url('index/login/zhuce_from')}" onsubmit="return fun(flag);" class="main">
    <div class="person1 person1_top">
        <div class="item"><span class="item-title">姓名</span><span class="item-content"><input id="name" name="name" class="input" type="text" placeholder="请输入真实姓名" required="required" oninvalid="setCustomValidity('请输入真实姓名');" oninput="setCustomValidity('');" ></span></div>
        <div class="item"><span class="item-title">性别</span><span class="item-content"><input checked class="sex" type="radio" name="sex" value="1">&nbsp;<span style="font-size:16px">男</span>&nbsp;&nbsp;&nbsp;<input class="sex" type="radio" name="sex" value="0">&nbsp;<span style="font-size:16px">女</span></span></div>
    </div>
    <div class="person1 person1_top">
        <div class="item"><span class="item-title">公司</span><span class="item-content"><input id="work" name="company" class="input" type="text" placeholder="请输入您的公司名" required="required" oninvalid="setCustomValidity('请输入您的公司名');" oninput="setCustomValidity('');"></span></div>
        <div class="item"><span class="item-title">职位</span>
            <span class="item-content">
            <select id="company" name="position">
                <option value="">请选择职位</option>
                {if condition="$position"}
                {foreach $position as $k=> $vo}
                <option value="{$vo['name']}">{$vo['name']}</option>
                {/foreach}
                {/if}
            </select>
        </span>
        </div>
    </div>
    <div class="person1 person1_top">
        <div class="item"><span class="item-title">推荐人</span><span class="item-content"><input id="" name="referee" class="input" type="text" placeholder="请输入对接销售姓名" oninput="setCustomValidity('');" ></span></div>

        <div class="item"><span class="item-title">电话</span><span class="item-content"><input name="tel" id="tel" class="input phone" type="tel" placeholder="请输入您的电话号码" required="required" oninvalid="setCustomValidity('请输入您的电话号码');" oninput="setCustomValidity('');">
            <input id="btnSendCode" type="button" value="获取验证码" class="getcode" style="font-size:12px"/> </span></div>
        <div class="item"><span class="item-title">验证码</span><span class="item-content"><input id="code" name="code" class="input code" type="tel" placeholder="请输入验证码" required="required" oninvalid="setCustomValidity('请输入验证码');" oninput="setCustomValidity('');"></span></div>
    </div>
    <button class="regist" type="submit">注册</button>
</form>
</body>
</html>
<script>
    // 取消提示的http地址显示
    window.alert = function(name) {
        var iframe = document.createElement("IFRAME");
        iframe.style.display = "none";
        iframe.setAttribute("src", 'data:text/plain,');
        document.documentElement.appendChild(iframe);
        window.frames[0].window.alert(name);
        iframe.parentNode.removeChild(iframe);
    }
    $(function(){
        function fun(flag){
            return flag;
        }
        $('#form').submit(function() {
            /* Act on the event */
            var position = $('#company').val();
            if(position == ""){
                alert('请选择职位');
                return false;
            }
        });
        $('#btnSendCode').click(function(){

            var InterValObj; //timer变量，控制时间
            var count = 120; //间隔函数，1秒执行
            var curCount;//当前剩余秒数
            var tel = $('#tel').val();



            if(tel == ""){
                alert('请输入您的电话号码');
            }else if(tel.length != 11){
                alert('请输入正确的电话号码');
            }else{
                $.post("{:Url('index/login/zhuce_code')}",{tel:tel},function(data){

                    if(data == 1){
                        alert('此手机号已注册');
                    }else if(data == 2){
                        alert('请注意接收验证码');
                        curCount = count;
                        var dealType; //验证方式
                        var uid=$("#uid").val();//用户uid

                        //设置button效果，开始计时
                        $(".getcode").css("color","#e1bbc2")
                        $("#btnSendCode").attr("disabled", "true");
                        $("#btnSendCode").val( + curCount + "秒再获取");
                        InterValObj = window.setInterval(function(){
                            if (curCount == 0) {
                                window.clearInterval(InterValObj);//停止计时器
                                $(".getcode").css("color","#a62037")
                                $("#btnSendCode").removeAttr("disabled");//启用按钮
                                $("#btnSendCode").val("重新获取");
                                code = ""; //清除验证码。如果不清除，过时间后，输入收到的验证码依然有效
                            }
                            else {
                                curCount--;
                                $("#btnSendCode").val( + curCount + "秒再获取");
                            }
                        }, 1000); //启动计时器，1秒执行一次
                        //向后台发送处理数据
                    }else if(data == 3){
                        alert('验证码发生失败');
                    }
                });
            }
        });

//timer处理函数

    })
</script>
<script>
    $(function(){
        $("#back").click(function(){
            window.history.go(-1);
        });
    })
</script>